import requests
from config import Base_url
class EmployeeApi(object):
    path="/api/sys/user"
    @classmethod
    def add_emp(cls, headers, body,):
        """
        新增员工
        :param headers: 请求头
        :param body:请求体
        :return:返回响应对象
        """
        url=Base_url+cls.path
        resp=requests.post(url,headers=headers,json=body)
        return resp


    @classmethod
    def modify_emp(cls,id,headers,body):
        """
        修改员工数据
        :param id: 员工id
        :param headers: 请求头
        :param body: 请求体
        :return:相应对象
        """
        url=Base_url+ cls.path+{id}
        resp=requests.put(url,headers=headers,json=body)
        return resp
    @classmethod
    def get_emp(cls,id,headers):
        """
        查询员工
        :param id: 员工id
        :param headers: 请求体
        :return: 返回响应对象
        """
        url=Base_url+ cls.path+{id}
        resp=requests.get(url,headers=headers)
        return resp

    @classmethod
    def delete_emp(cls,id,headers):
        """
        删除员工
        :param id: 员工id
        :param headers: 请求头
        :return: 返回响应对象
        """
        url=Base_url+ cls.path+{id}
        resp=requests.delete(url,headers=headers)
        return resp



if __name__ == '__main__':
    # headers = {"Authorization": "Bearer f566b182-6b62-4fae-aa66-2fe29356165e"}
    # body={"username": "YG001", "mobile": "18210222378","workNumber": "123"}
    # data=EmployeeApi.add_emp(headers,body)
    # print(data.json())


    # id="1551470064337694720"
    # headers = {"Authorization": "Bearer f566b182-6b62-4fae-aa66-2fe29356165e"}
    # body={"username": "YG002","password": "123456","departmentId": "10086"}
    # data=EmployeeApi.modify_emp(id,headers,body)
    # print(data.json())


    # id="1551470064337694720"
    # headers = {"Authorization": "Bearer f566b182-6b62-4fae-aa66-2fe29356165e"}
    # data=EmployeeApi.get_emp(id,headers)
    # print(data.json())

    id="1551470064337694720"
    headers={"Authorization": "Bearer f566b182-6b62-4fae-aa66-2fe29356165e"}
    data=EmployeeApi.delete_emp(id,headers)
    print(data.json())
